package com.ruoyi.web.controller.mk;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mk.domain.MkZdrz;
import com.ruoyi.mk.service.IMkZdrzService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 终端日志Controller
 * 
 * @author guan
 * @date 2021-12-13
 */
@RestController
@RequestMapping("/mk/zdrz")
public class MkZdrzController extends BaseController
{
    @Autowired
    private IMkZdrzService mkZdrzService;

    /**
     * 查询终端日志列表
     */
    @PreAuthorize("@ss.hasPermi('mk:zdrz:list')")
    @GetMapping("/list")
    public TableDataInfo list(MkZdrz mkZdrz)
    {
        startPage();
        List<MkZdrz> list = mkZdrzService.selectMkZdrzList(mkZdrz);
        return getDataTable(list);
    }

    /**
     * 导出终端日志列表
     */
    @PreAuthorize("@ss.hasPermi('mk:zdrz:export')")
    @Log(title = "终端日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MkZdrz mkZdrz)
    {
        List<MkZdrz> list = mkZdrzService.selectMkZdrzList(mkZdrz);
        ExcelUtil<MkZdrz> util = new ExcelUtil<MkZdrz>(MkZdrz.class);
        return util.exportExcel(list, "终端日志数据");
    }

    /**
     * 获取终端日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('mk:zdrz:query')")
    @GetMapping(value = "/{rzId}")
    public AjaxResult getInfo(@PathVariable("rzId") Long rzId)
    {
        return AjaxResult.success(mkZdrzService.selectMkZdrzByRzId(rzId));
    }

    /**
     * 新增终端日志
     */
    @PreAuthorize("@ss.hasPermi('mk:zdrz:add')")
    @Log(title = "终端日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MkZdrz mkZdrz)
    {
        return toAjax(mkZdrzService.insertMkZdrz(mkZdrz));
    }

    /**
     * 修改终端日志
     */
    @PreAuthorize("@ss.hasPermi('mk:zdrz:edit')")
    @Log(title = "终端日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MkZdrz mkZdrz)
    {
        return toAjax(mkZdrzService.updateMkZdrz(mkZdrz));
    }

    /**
     * 删除终端日志
     */
    @PreAuthorize("@ss.hasPermi('mk:zdrz:remove')")
    @Log(title = "终端日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rzIds}")
    public AjaxResult remove(@PathVariable Long[] rzIds)
    {
        return toAjax(mkZdrzService.deleteMkZdrzByRzIds(rzIds));
    }
}
